namespace AutoTest.Core.TestRunners.XUnit
{
    using System;
    using System.Collections.Generic;
    using Xunit;

    public class XUnitRunnerLogger : IRunnerLogger
    {
        public XUnitRunnerLogger()
        {
            Results = new List<TestResult>();
        }

        public ICollection<TestResult> Results { get; private set; }

        public void AssemblyFinished(string assemblyFilename, int total, int failed, int skipped, double time)
        {
        }

        public void AssemblyStart(string assemblyFilename, string xUnitVersion)
        {
        }

        public bool ClassFailed(string className, string exceptionType, string message, string stackTrace)
        {
            return true;
        }

        public void ExceptionThrown(string assemblyFilename, Exception exception)
        {
        }

        public void TestFailed(string name, string type, string method, double duration, string exceptionType, string message,
                               string stackTrace)
        {
            Results.Add(TestResult.Fail(message));
        }

        public bool TestFinished(string name, string type, string method, double duration, string output)
        {
            return true;
        }

        public void TestPassed(string name, string type, string method, double duration)
        {
            Results.Add(TestResult.Pass());
        }

        public void TestSkipped(string name, string type, string method, string reason)
        {
            Results.Add(new TestResult(TestStatus.Ignored, reason));
        }

        public bool TestStart(string name, string type, string method)
        {
            return true;
        }

        public void TransformStart(string outputType, string filename)
        {
        }
    }
}